package twoDayMoreThread.BaoZi;

public class ChiHuo extends Thread{
    private BaoZi bz;
    public ChiHuo(BaoZi bz){
        this.bz=bz;
    }

    @Override
    public void run() {
       while (true){
           synchronized (bz){
               if (bz.flag==false){
                   try {
                       bz.wait();//等待生产
                   } catch (InterruptedException e) {
                       e.printStackTrace();
                   }
               }
               System.out.println("吃货正在吃："+bz.pi+bz.xian+"的包子");

               bz.flag=false;//修改包子的状态
               bz.notify();//唤醒包子铺线程，生产包子
               System.out.println("吃货已经把："+bz.pi+bz.xian+"的包子吃完了，包子铺开始生产包子");
           }
       }
    }
}
